package com.sduonline.isdapp.config;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.ParseException;
import java.util.Properties;

import com.sduonline.isdapp.util.TimeUtil;

public class AutoServiceTriggerConfig {

	public static boolean isOpenAutoParser = false;
	public static long st = 1459440000;// 2016-04-01
	public static long et = System.currentTimeMillis() / 1000;

	static {
		try {
			Properties props = new Properties();
			String srcPath = BaseConfig.class.getResource("/").getPath();
			try {
				srcPath = URLDecoder.decode(srcPath, "UTF-8");
			} catch (UnsupportedEncodingException e) {
				srcPath = BaseConfig.ROOT.replace("%20", " ");
				e.printStackTrace();
			}
			props.load(new FileInputStream(new File(srcPath + "/" + "ishanda.properties")));
			isOpenAutoParser = Boolean.parseBoolean(props.getProperty("isOpenAutoParser", "false"));
			st = TimeUtil.convertToTimestamp(props.getProperty("st", "2016-04-01")).getTime() / 1000;
			et = TimeUtil.convertToTimestamp(props.getProperty("et", TimeUtil.formatCurrentTime())).getTime() / 1000;
			System.out.println("isOpenAutoParser:" + isOpenAutoParser);
			System.out.println("st:" + st);
			System.out.println("et:" + et);

		} catch (IOException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
